package notes.designpattern.java.d1_danyiyuanze;

/**
 * 单一职责原则
 */
public class Danyiyuanze2 {

	public static void main(String[] args) {
		RoadVehicle v1 = new RoadVehicle();
		v1.run("摩托车");
		v1.run("汽车");
		
		WaterVehicle v2 = new WaterVehicle();
		v2.run("轮船");
		
		PlayVehicle v3 = new PlayVehicle();
		v3.run("飞机");
	}
}

// 交通工具类(公路)
class RoadVehicle {
	public void run(String name) {
		System.out.println(name + "->在路上运行");
	}
}

//交通工具类(水路)
class WaterVehicle {
	public void run(String name) {
		System.out.println(name + "->在水上运行");
	}
}

//交通工具类(飞行)
class PlayVehicle {
	public void run(String name) {
		System.out.println(name + "->在空中运行");
	}
}
